#include "TaskGraph.h"

void AsyncTask(uint32 threadId, std::function<void()> func)
{
	GraphTask<AsyncGraphTask>::CreateTask().ConstructAndDispatchWhenReady(threadId, std::move(func));
}

GraphEventRef GraphEvent::CreateGraphEvent()
{
	return RefCountPtr<GraphEvent>(NewShare<GraphEvent>());
}

void GraphEvent::DispatchSubsequents()
{
	mIsCompleted.store(true);

	BaseGraphTask* newTask;
	while (mSubsequentList.Pop(&newTask))
	{
		assert(newTask != nullptr);
		newTask->ConditionalQueueTask();
	}
}
